package com.clkj.aimin.dao.helper;

import com.clkj.aimin.pojo.helper.HelperTalk;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface HelperTalkMapper extends Mapper<HelperTalk> {
    @Select("SELECT h.*, u.user_name, u.user_img FROM t_cl_helperTalk h LEFT JOIN t_cl_user u ON h.user_id = u.user_id \n" +
            "INNER JOIN ( SELECT user_id, helper_id, MAX(create_time) AS last_message_time FROM t_cl_helperTalk GROUP BY user_id, helper_id) \n" +
            "latest ON h.user_id = latest.user_id AND h.helper_id = latest.helper_id AND h.create_time = latest.last_message_time and h.helper_id=#{helperId}")
    List<HelperTalk> getHelperTalkInfo(Integer helperId);
}
